<template>
	<IForm ref="form" :model="form" inline :label-width="60">
		<FormItem prop="phone" label="手机号">
			<IInput  placeholder="手机号" v-model="form.phone" ></IInput>
		</FormItem>
		<FormItem prop="time" label="发送时间">
			<DatePicker type="datetimerange" v-model="form.time" format="yyyy-MM-dd HH:mm" style="width: 300px" placeholder="发送时间"></DatePicker>
		</FormItem>
		<FormItem prop="status" label="发送状态">
			<ISelect v-model="form.status">
			    <IOption v-for="item in status" :value="item.id" :key="item.id">{{ item.name }}</IOption>
			</ISelect>
		</FormItem>
		<FormItem prop="isCheck" label="是否验证" v-model="form.isCheck">
			<ISelect  v-model="form.isCheck">
			    <IOption v-for="item in checks" :value="item.id" :key="item.id">{{ item.name }}</IOption>
			</ISelect>
		</FormItem>
		<FormItem>
			<IButton type="primary" @click="handleSubmit">筛选</IButton>
		</FormItem>
	</IForm>
</template>
<script>
	import Form from 'iview/src/components/form';
	import DatePicker from 'iview/src/components/date-picker';
	import Input from 'iview/src/components/input';
	import {Select, Option, OptionGroup} from 'iview/src/components/select';
	import Button from 'iview/src/components/button';

	export default{
		components:{
			'IForm' : Form,
			'FormItem' : Form.Item,
            DatePicker,
            'IInput' : Input,
            'ISelect' : Select,
            'IOption' : Option,
            'IButton' : Button,
        },
        data () {
            return {
            	form :{
            		phone : '',
            		time : '',
            		status : '',
            		isCheck : '',
            	},
            	status : [
        			{id : 0,name : '失败'},
        			{id : 1,name : '成功'}
        		],
        		checks : [
        			{id : 0,name : '否'},
        			{id : 1,name : '是'}
        		]
            }
        },
        methods: {
            handleSubmit() {
            	if(this.form.time[0]!=''){
            		var startTime = new Date(this.form.time[0]),
	            		endTime = new Date(this.form.time[1]);
	            	this.form['time'][0] = startTime.toLocaleDateString().replace(/\//g, "-") + " " + startTime.toTimeString().substr(0, 5);
	            	this.form['time'][1] = endTime.toLocaleDateString().replace(/\//g, "-") + " " + endTime.toTimeString().substr(0, 5);
            	}
            	this.$emit('refreshTable',this.form);
            }
        }

	}
</script>